package com.school.campus.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.school.common.annotation.Log;
import com.school.common.core.controller.BaseController;
import com.school.common.core.domain.AjaxResult;
import com.school.common.enums.BusinessType;
import com.school.campus.domain.TeachingResearchOffice;
import com.school.campus.service.ITeachingResearchOfficeService;
import com.school.common.utils.poi.ExcelUtil;
import com.school.common.core.page.TableDataInfo;

/**
 * 教研室信息Controller
 * 
 * @author wwj
 * @date 2025-10-31
 */
@RestController
@RequestMapping("/campus/office")
public class TeachingResearchOfficeController extends BaseController
{
    @Autowired
    private ITeachingResearchOfficeService teachingResearchOfficeService;

    /**
     * 查询教研室信息列表
     */
    @PreAuthorize("@ss.hasPermi('campus:office:list')")
    @GetMapping("/list")
    public TableDataInfo list(TeachingResearchOffice teachingResearchOffice)
    {
        startPage();
        List<TeachingResearchOffice> list = teachingResearchOfficeService.selectTeachingResearchOfficeList(teachingResearchOffice);
        return getDataTable(list);
    }

    /**
     * 导出教研室信息列表
     */
    @PreAuthorize("@ss.hasPermi('campus:office:export')")
    @Log(title = "教研室信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TeachingResearchOffice teachingResearchOffice)
    {
        List<TeachingResearchOffice> list = teachingResearchOfficeService.selectTeachingResearchOfficeList(teachingResearchOffice);
        ExcelUtil<TeachingResearchOffice> util = new ExcelUtil<TeachingResearchOffice>(TeachingResearchOffice.class);
        util.exportExcel(response, list, "教研室信息数据");
    }

    /**
     * 获取教研室信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('campus:office:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(teachingResearchOfficeService.selectTeachingResearchOfficeById(id));
    }

    /**
     * 新增教研室信息
     */
    @PreAuthorize("@ss.hasPermi('campus:office:add')")
    @Log(title = "教研室信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TeachingResearchOffice teachingResearchOffice)
    {
        return toAjax(teachingResearchOfficeService.insertTeachingResearchOffice(teachingResearchOffice));
    }

    /**
     * 修改教研室信息
     */
    @PreAuthorize("@ss.hasPermi('campus:office:edit')")
    @Log(title = "教研室信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TeachingResearchOffice teachingResearchOffice)
    {
        return toAjax(teachingResearchOfficeService.updateTeachingResearchOffice(teachingResearchOffice));
    }

    /**
     * 删除教研室信息
     */
    @PreAuthorize("@ss.hasPermi('campus:office:remove')")
    @Log(title = "教研室信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(teachingResearchOfficeService.deleteTeachingResearchOfficeByIds(ids));
    }
}
